home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
PET
/
S-Super PET
/
(s)t4.d64
/
CONCENTRATE.BAS
< prev
next >
Wrap
BASIC Source File
|
2009-01-18
|
8KB
|
237 lines
100 ! Concentration
200 ! Written by: J.B.Schueler and B.J.Stecher,
300 ! Waterloo Computing Systems Limited (WATCOM),
400 ! 415 Phillip St.,
500 ! Waterloo, Ontario, Canada N2L 3E9
600 option base 1
700 randomize
800 dim doors%(25),items$(13),match%(25),memory%(25)
1000 print chr$(12);
1100 print " Welcome to WATSoft's game of"
1200 call dis(".----------+----------+----------+----------+----------.")
1300 call dis("|1 |2 |3 |4 |5 |")
1400 call dis("| | | | | |")
1500 call dis("| | | | | |")
1600 call dis("+----------+----------+----------+----------+----------+")
1700 call dis("|6 |7 |8 |9 |10 |")
1800 call dis("| | | | | |")
1900 call dis("| | | | | |")
2000 call dis("+----------+----------+----------+----------+----------+")
2100 call dis("|11 |12 |13 |14 |15 |")
2200 call dis("| | | | | |")
2300 call dis("| | | | | |")
2400 call dis("+----------+----------+----------+----------+----------+")
2500 call dis("|16 |17 |18 |19 |20 |")
2600 call dis("| | | | | |")
2700 call dis("| | | | | |")
2800 call dis("+----------+----------+----------+----------+----------+")
2900 call dis("|21 |22 |23 |24 |25 |")
3000 call dis("| | | | | |")
3100 call dis("| | | | | |")
3200 call dis(".----------+----------+----------+----------+----------.")
3300 proc dis(x$)
3400 print x$
3500 endproc
3600 print " CONCENTRATION"
3700 x=cursor( 2*80-22 )
3800 print "Match pairs of hidden"
3900 x=cursor(3*80-22)
4000 print "items by choosing two"
4100 x=cursor(4*80-22)
4200 print "door numbers. What lies"
4300 x=cursor(5*80-22)
4400 print "behind each door will"
4500 x=cursor(6*80-22)
4600 print "be revealed to you. Try"
4700 x=cursor(7*80-22)
4800 print "to remember what is"
4900 x=cursor(8*80-22)
5000 print "behind each door. Find"
5100 x=cursor(9*80-22)
5200 print "more items than the"
5300 x=cursor(10*80-22)
5400 print "computer to win."
5500 mat read items$
5600 for i%=1 to 24
5700 doors%(i%)=1+mod(i%,12)
5800 next i%
5900 computer_wins = 0
6000 player_wins = 0
6100 x=cursor(23*80-20)
6200 print "ME";computer_wins;" YOU";player_wins
6300 doors%(i%)=13
6400 for i%=1 to 25
6500 exch%=rnd*25+1
6600 temp%=doors%(exch%)
6700 doors%(exch%)=doors%(i%)
6800 doors%(i%)=temp%
6900 match%(i%)=0
7000 memory%(i%)=0
7100 next i%
7200 x=cursor(18*80-22)
7300 input "Start? ",reply$
7400 if reply$(1:1)="n" then goto 23700
7500 loop
7600 call computer_turn
7700 if computer_wins > 6 then quit
7800 call player_turn
7900 if player_wins > 6 then quit
8000 endloop
8100 x=cursor(1)
8200 for i%=1 to 25
8400 call open_door(i%)
8500 next i%
8600 call sleep(20)
8700 for i%=1 to 25
8800 call close_door(i%)
8900 next i%
9000 x=cursor(18*80-22)
9100 print chr$(6)
9200 goto 5600
9300 proc computer_turn
9400 x=cursor(23*80-20)
9500 print "ME"
9600 if player_wins+computer_wins < 12
9700 call guess_door
9800 call check_doors
9900 else
10000 win%=1
10100 endif
10200 computer_wins = computer_wins + win%
10300 x=cursor(23*80-20)
10400 print "ME";computer_wins;
10500 endproc
10600 proc guess_door
10700 guess
10800 door1% = 0
10900 door2% = 0
11000 call match_look
11100 if door1% <> 0 then quit
11200 door1% = fnpick_door%
11300 call match_look
11400 if door2% <> 0 then quit
11500 door2% = fnpick_door%
11600 endguess
11700 x=cursor(12*80-22)
11800 print "DOOR? ";door1%;chr$(6)
11900 x=cursor(14*80-21)
12000 print "and"
12100 x=cursor(16*80-22)
12200 print "DOOR? ";door2%;chr$(6)
12300 call open_door( door1% )
12400 call open_door( door2% )
12500 endproc
12600 proc match_look
12700 for i% = 1 to 24
12800 if match%( i% ) = 0 and memory%( i% ) <> 0
12900 for j% = i% + 1 to 25
13000 if match%( j% ) = 0
13100 if memory%( i% ) = memory%( j% )
13200 door1% = i%
13300 door2% = j%
13400 goto 14000
13500 endif
13600 endif
13700 next j%
13800 endif
13900 next i%
14000 endproc
14100 def fnpick_door%
14200 for i% = 1 to 25
14300 if match%( i% ) = 0 and memory%( i% ) = 0 then quit
14400 next i%
14500 memory%( i% ) = doors%( i% )
14600 fnpick_door% = i%
14700 fnend
14800 proc player_turn
14900 x=cursor(23*80-10)
15000 print "YOU"
15100 if player_wins+computer_wins < 12
15200 call select_door
15300 call check_doors
15400 else
15500 win% = 1
15600 endif
15700 player_wins = player_wins + win%
15800 x=cursor(23*80-10)
15900 print "YOU";player_wins;
16000 endproc
16100 proc select_door
16200 on conv
16300 conv%=1
16400 resume next
16500 endon
16600 x=cursor(12*80-15)
16700 print chr$(6)
16800 x=cursor(16*80-15)
16900 print chr$(6)
17000 loop
17100 x=cursor(12*80-22)
17200 print "DOOR? ";chr$(6);
17300 conv%=0
17400 input "",door1%
17500 if conv% = 1 then goto 17100
17600 if door1% > 25 then goto 17100
17700 if match%( door1% ) = 0 then quit
17800 x=cursor(13*80-22)
17900 print "Try a closed door"
18000 endloop
18100 x=cursor(13*80-22)
18200 print chr$(6)
18300 call open_door( door1% )
18400 x=cursor(14*80-21)
18500 print "and"
18600 loop
18700 x=cursor(16*80-22)
18800 print "DOOR? ";chr$(6);
18900 conv% = 0
19000 input "",door2%
19100 if conv% = 1 then goto 18700
19200 if door2% > 25 then goto 18700
19300 if match%( door2% ) = 0 and door1% <> door2% then quit
19400 x=cursor(17*80-22)
19500 print "Try a closed door"
19600 endloop
19700 x=cursor(17*80-22)
19800 print chr$(6)
19900 call open_door( door2% )
20000 memory%( door1% ) = doors%( door1% )
20100 memory%( door2% ) = doors%( door2% )
20200 endproc
20300 proc check_doors
20400 guess
20500 if doors%( door1% ) = doors%( door2% ) then quit
20600 if doors%( door1% ) = 13 then quit
20700 if doors%( door2% ) = 13 then quit
20800 call sleep( 5 )
20900 call close_door( door1%)
21000 call close_door( door2%)
21100 win% = 0
21200 admit
21300 match%( door1% ) = 1
21400 match%( door2% ) = 1
21500 win% = 1
21600 endguess
21700 endproc
21800 proc open_door( door% )
21900 row%=int((door%-1)/5) * 4 + 3
22000 col%=( mod(door%-1,5) ) * 11 + 2
22100 x=cursor( row%*80+col% )
22200 print items$( doors%(door%) )
22300 endproc
22400 proc close_door( door% )
22500 row%=int((door%-1)/5) * 4 + 3
22600 col%=( mod(door%-1,5) ) * 11 + 2
22700 x=cursor( row%*80+col% )
22800 print " "
22900 endproc
23000 proc sleep( amount )
23100 for i=1 to amount * 350
23200 next i
23300 endproc
23400 data "WATSoft","WATCOM","ECOO","M6809","micro"
23500 data "BASIC","FORTRAN","APL","Pascal","COBOL","Assembler","Linker"
23600 data "* Wild *"
23700 x=cursor(21*80+1)
23900 end